#pragma once
#if defined(WIN32) || defined(_WIN32)
#include "windows/Dongle_API.h"
#else
#include "linux/Dongle_API.h"
#endif

#include <memory>
#include <atomic>
#include <string>

#pragma  pack (push,1) 
struct DongleInfo
{
	char channel_name[64];
	char product_type[64];
	char version[20];
	char branch_name[64];

	long long	 create_time;

	//char create_time[20];
};
#pragma pack(pop)

class SimOneLicense {
public:
	SimOneLicense();
	~SimOneLicense();

	DONGLE_INFO* getCardDongleInfo() { return &mCardDongleInfo; }
	DongleInfo* getDongleInfo() { return &mDongleInfo; }
	unsigned long getDDeadTime() { return mDDeadTime; }

	unsigned long InitDog();
	unsigned long CheckDog();
	void StopDongleThread();
	bool getDongleExist();

	bool IsUserDog();
private:
	void GenerateThread();
	class LicenseImplFake;

	bool mDongle;

	unsigned long mDRet;
	int mDCount;
	DONGLE_HANDLE mhDongle;
	DONGLE_INFO mCardDongleInfo;
	std::string mAdminPin;
	int mRemainCount;
	DongleInfo mDongleInfo;
#if defined(WIN32) || defined(_WIN32)
	unsigned long mDUTCTime;
	unsigned long mDDeadTime;
	std::string mDDeadTimeStr;
#else
	unsigned int mDUTCTime;
	unsigned int mDDeadTime;
	std::string mDDeadTimeStr;
#endif
	std::atomic<bool> mDongleExist;
	std::atomic<bool> mDongleThreadRunning;

};

